package com.alex.ioc.lifecycle;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;



public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("before init "+beanName+ " ...");
        if (bean.getClass() == Car.class) {
            System.out.println("it is a car");
            ((Car) bean).setBrand("bmw");
        }
        return new Car();
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("after init " + beanName +" ...");
        return bean;
    }


}
